#ifndef __GAME_ACTION_HPP__
#define __GAME_ACTION_HPP__

#include <vector>
#include <functional>

// 类 C#的Action类 的简单实现

template<typename... Args>
class GameAction {
public:
    using FuncType = std::function<void(Args...)>;

    inline void operator+=(FuncType func) {
        m_actions.push_back(func);
    }

    inline void operator()(Args... args) {
        for (auto& action : m_actions) {
            action(args...);
        }
    }

    inline void invoke(Args... args)
    {
        for (auto& action : m_actions) {
            action(args...);
        }
    }

private:
    std::vector<FuncType> m_actions;
};

#endif
